package com.hmall.search.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {
    @Bean
    public DirectExchange itemDirect() {
        return new DirectExchange("item.direct");
    }
    @Bean
    public Queue startQueue() {
        return new Queue("start.queue");
    }
    @Bean
    public Queue endQueue() {
        return new Queue("end.queue");
    }
    @Bean
    public Binding bindingUpQueue(DirectExchange itemDirect, Queue startQueue){
        return BindingBuilder.bind(startQueue).to(itemDirect).with("item.start");
    }
    @Bean
    public Binding bindingDownQueue(DirectExchange itemDirect,Queue endQueue){
        return BindingBuilder.bind(endQueue).to(itemDirect).with("item.end");
    }
}